home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2614.ZIP / TBROWS.ZIP / TTBR4.PRG < prev    next >
Text File  |  1990-10-22  |  3KB  |  146 lines

  1. /*****
  2.  *
  3.  * TTBR4.PRG
  4.  * Fourth example for TBROWSE class using a database file
  5.  *
  6.  * 19 October 90
  7.  * Luiz Quintela - Nantucket Corp
  8.  *
  9.  * Clipper ttbr4 /N/W/A/B
  10.  * RTLINK FILE ttbr4 PLL base50
  11.  *
  12.  */
  13.  
  14. // Include Header Files
  15. #include "inkey.ch"
  16. #include "setcurs.ch"
  17.  
  18. FUNCTION Main()
  19. LOCAL b, column, nKey
  20. SET SCOREBOARD OFF
  21. SET DATE       BRITISH
  22. SET CONFIRM    ON
  23.  
  24. USE test INDEX test NEW
  25. // Turn cursor off
  26. SETCURSOR(SC_NONE)
  27. SETCOLOR( "BG/B,GR+/B,,,BG/N" ); CLS
  28.  
  29. b := TBrowseDB( 2, 2, 20, 48)
  30.  
  31. b:colSep := " │ "
  32. b:headSep := "═╤═"
  33. b:footSep := "═══"
  34.  
  35. // TBColumn objects
  36. column := TBColumnNew( "Field 1", {|| test->fld1} )
  37. column:footing := "First"
  38. b:addColumn( column )
  39. column := TBColumnNew( "Field 2", {|| test->fld2} )
  40. b:addColumn( column )
  41. column := TBColumnNew( "Field 3", {|| test->fld3} )
  42. b:addColumn( column )
  43. column := TBColumnNew( "Field 4", {|| test->fld4} )
  44. b:addColumn( column )
  45. column := TBColumnNew( "Field 5", {|| test->fld5} )
  46. column:footing := "Last"
  47. b:addColumn( column )
  48.  
  49. // One useful thing: freeze one or more columns in the screen
  50. // You could accomplish this using the instance variable 
  51. // freeze. It defines the number of data columns frozen
  52. // on the feft side of the display
  53. b:freeze := 1
  54.  
  55. WHILE .T.
  56.    // Do not allow cursor to move into frozen columns
  57.    // (Optional!)
  58.    // You will use the instance variable colPos to get
  59.    // current cursor column position
  60.    IF  ( b:colPos <= 1 )
  61.        // As you can see b:colPos is assignable
  62.        b:colPos := b:freeze + 1
  63.  
  64.    ENDIF
  65.  
  66.    // Stabilization
  67.    WHILE ( !b:stabilize() )
  68.       nKey := InKey()
  69.       IF ( nKey != 0 )
  70.          EXIT // abort if a key is waiting
  71.  
  72.       ENDIF
  73.  
  74.    END
  75.  
  76.    IF ( b:stable )
  77.       // Is always a good idea tell the user about end or 
  78.       // beginning of file
  79.       // b:hitTop contais a .T. if an attempt was made 
  80.       // to navigate beyond the beginning of data source
  81.       // b:hitBottom contais a .T. if an attempt was made 
  82.       // to navigate beyond the end of data source
  83.  
  84.       IF ( b:hitTop .OR. b:hitBottom )
  85.           TONE(87.3,1)
  86.          TONE(40,3.5)
  87.  
  88.       ENDIF
  89.  
  90.       // everything's done; just wait for a key
  91.       nKey := INKEY(0)         
  92.  
  93.    ENDIF
  94.  
  95.    // Process key
  96.     IF ( nKey == K_DOWN )
  97.       b:down()
  98.  
  99.    ELSEIF ( nKey == K_UP )
  100.       b:up()
  101.  
  102.    ELSEIF ( nKey == K_PGDN )
  103.       b:pageDown()
  104.  
  105.    ELSEIF ( nKey == K_PGUP )
  106.       b:pageUp()
  107.  
  108.    ELSEIF ( nKey == K_CTRL_PGUP )
  109.       b:goTop()
  110.  
  111.    ELSEIF ( nKey == K_CTRL_PGDN )
  112.       b:goBottom()
  113.  
  114.    ELSEIF ( nKey == K_RIGHT )
  115.       b:right()
  116.  
  117.    ELSEIF ( nKey == K_LEFT )
  118.       b:left()
  119.  
  120.    ELSEIF ( nKey == K_HOME )
  121.       b:home()
  122.  
  123.    ELSEIF ( nKey == K_END )
  124.       b:end()
  125.  
  126.    ELSEIF ( nKey == K_CTRL_LEFT )
  127.       b:panLeft()
  128.  
  129.    ELSEIF ( nKey == K_CTRL_RIGHT )
  130.       b:panRight()
  131.  
  132.    ELSEIF ( nKey == K_CTRL_HOME )
  133.       b:panHome()
  134.  
  135.    ELSEIF ( nKey == K_CTRL_END )
  136.       b:panEnd()
  137.  
  138.    ELSEIF ( nKey == K_ESC )
  139.         CLS; SETCURSOR(SC_NORMAL); QUIT
  140.  
  141.     ENDIF
  142.  
  143. END
  144.  
  145. /* EOF - TTBR4.PRG */
  146.